Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update libbacktrace #50955

Merged
merged 2 commits into from
May 30, 2018
Merged

Update libbacktrace #50955

merged 2 commits into from
May 30, 2018

Conversation

steveklabnik
Copy link
Member

We haven't updated libbacktrace in two years. This is just blindly updating to the latest HEAD; I'd like to see what travis says. It at least builds on my machine, running some tests...

This perpetuates the patches from #30908

@retep998
Copy link
Member

retep998 commented May 22, 2018

Can I question why this includes THE ADVENTURES OF TOM SAWYER !?!?

@petrochenkov
Copy link
Contributor

A number of other patches was applied to our version of libbacktrace after #30908 if you look at git history, Mach-O support in particular.

@kennytm kennytm added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 22, 2018
@steveklabnik
Copy link
Member Author

@petrochenkov thanks, good call. I figured there may be more; I hadn't fully checked into it yet. I'll go take a look now that it did build successfully.

@steveklabnik
Copy link
Member Author

I've reapplied some patches, and disregarded some others. A double check here would be great.

Spelling fixes, that I've disregarded so that we closer track upstream:

Backports that should be included with the update:

e8121b3 added support for apple platforms, but then 8581b59 disabled it, so I've just not bothered. The original patch was sent upstream, but was ignored and eventually closed.

For aa6bd11, the file was completely deleted upstream, and so I don't think applies anymore.

@kennytm
Copy link
Member

kennytm commented May 22, 2018

(I'd prefer us to transition to a gimli-based library eventually so I'm 👎 to merging this huge PR.)

8581b59 (#45866) only disabled mmap support for macOS, not the entire functionality.

The upstream patch ianlancetaylor/libbacktrace#2 was closed because the maintainer simply ignored the PR without any further communication. It doesn't mean the patch is not working.

BTW is it possible we just turn libbacktrace into a submodule? +18846/-8114 isn't a fun thing to deal with.

@sfackler
Copy link
Member

A submodule seems like a good idea.

@alexcrichton
Copy link
Member

r? @alexcrichton

@alexcrichton
Copy link
Member

I believe at the time that this was originally added the repo didn't exist or I couldn't find it, but I definitely agree that we should use a submodule now. If anything it'll help us track how we diverge! To that end I've now created https://github.com/rust-lang-nursery/libbacktrace

Ok and to make sure we don't lose anything, let's take a look at the current history of the "submodule". The commits we're dealing with are:

And I believe that's it. 5f57121, the next element in the history, is where we reset to a revision of upstream gcc, so it's sync'd with the original source. I agree with @steveklabnik to leave out typos, which leaves us with:

and I believe that's everything? The stack of commits is the tip of the rust-snapshot-2018-05-22 branch of that repo.

@kennytm I agree that eventually we want to move away from libbacktrace, but unfortunately that's a much larger change so for the time being I think an incremental update moving us towards the submodule should probably be sufficient

@steveklabnik do you want to update this PR to add a submodule to the repo I've created?

@alexcrichton
Copy link
Member

@steveklabnik also while you're at it, can you update the backtrace and backtrace-sys crates?

@steveklabnik
Copy link
Member Author

steveklabnik commented May 22, 2018 via email

@alexcrichton alexcrichton force-pushed the update-libbacktrace branch from 3ec7aa5 to 6691dae Compare May 23, 2018 02:42
@alexcrichton
Copy link
Member

@bors: r+

No worries! I've pushed the changes here and let's see what bors thinks of this.

@bors
Copy link
Contributor

bors commented May 23, 2018

📌 Commit 6691dae has been approved by alexcrichton

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 23, 2018
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-3.9 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[00:00:00] Attempting with retry: sh -c rm -f download-src-doc-book.tar.gz &&         curl -sSL -o download-src-doc-book.tar.gz https://github.com/rust-lang/book/archive/36d65d00164d1750f6fa7f8b0f52dabc3fea500b.tar.gz
[00:00:00] rm 'src/doc/rust-by-example'
[00:00:00] Attempting with retry: sh -c rm -f download-src-doc-rust-by-example.tar.gz &&         curl -sSL -o download-src-doc-rust-by-example.tar.gz https://github.com/rust-lang/rust-by-example/archive/eebda16e4b45f2eed4310cf7b9872cc752278163.tar.gz
[00:00:00] rm 'src/llvm-emscripten'
[00:00:00] Attempting with retry: sh -c git submodule deinit -f  src/jemalloc src/tools/rust-installer src/liblibc src/doc/nomicon src/tools/cargo src/doc/reference src/tools/rls src/libcompiler_builtins src/tools/clippy src/tools/rustfmt src/tools/miri src/dlmalloc src/stdsimd src/tools/lld src/libbacktrace &&     git submodule sync &&     git submodule update -j 16 --init --recursive  src/jemalloc src/tools/rust-installer src/liblibc src/doc/nomicon src/tools/cargo src/doc/reference src/tools/rls src/libcompiler_builtins src/tools/clippy src/tools/rustfmt src/tools/miri src/dlmalloc src/stdsimd src/tools/lld src/libbacktrace
[00:00:00] Cleared directory 'src/dlmalloc'
[00:00:00] Cleared directory 'src/doc/nomicon'
[00:00:00] Cleared directory 'src/doc/reference'
[00:00:00] Cleared directory 'src/jemalloc'
---
[00:00:00] Submodule 'src/dlmalloc' (https://github.com/alexcrichton/dlmalloc-rs.git) registered for path 'src/dlmalloc'
[00:00:00] Submodule 'src/doc/nomicon' (https://github.com/rust-lang-nursery/nomicon.git) registered for path 'src/doc/nomicon'
[00:00:00] Submodule 'src/doc/reference' (https://github.com/rust-lang-nursery/reference.git) registered for path 'src/doc/reference'
[00:00:00] Submodule 'src/jemalloc' (https://github.com/rust-lang/jemalloc.git) registered for path 'src/jemalloc'
[00:00:00] Submodule 'src/libbacktrace' (https://github.com/rust-lang-nursery/libbacktrace) registered for path 'src/libbacktrace'
[00:00:00] Submodule 'src/liblibc' (https://github.com/rust-lang/libc.git) registered for path 'src/liblibc'
[00:00:00] Submodule 'src/stdsimd' (https://github.com/rust-lang-nursery/stdsimd) registered for path 'src/stdsimd'
[00:00:00] Submodule 'src/tools/cargo' (https://github.com/rust-lang/cargo.git) registered for path 'src/tools/cargo'
[00:00:00] Submodule 'src/tools/clippy' (https://github.com/rust-lang-nursery/rust-clippy.git) registered for path 'src/tools/clippy'
---
[00:00:07] Submodule path 'src/dlmalloc': checked out 'c99638dc2ecfc750cc1656f6edb2bd062c1e0981'
[00:00:07] Submodule path 'src/doc/nomicon': checked out '748a5e6742db4a21c4c630a58087f818828e8a0a'
[00:00:07] Submodule path 'src/doc/reference': checked out '134f419ee62714590b04712fe6072253bc2a7822'
[00:00:07] Submodule path 'src/jemalloc': checked out '1f5a28755e301ac581e2048011e4e0ff3da482ef'
[00:00:08] Submodule path 'src/libbacktrace': checked out '7845b4ecc7e8a6856ea42bb0f1f6bfcdbb8926ca'
[00:00:08] Submodule 'compiler-rt' (https://github.com/rust-lang/compiler-rt) registered for path 'src/libcompiler_builtins/compiler-rt'
[00:00:08] Cloning into '/home/travis/build/rust-lang/rust/src/libcompiler_builtins/compiler-rt'...
[00:00:11] Submodule path 'src/libcompiler_builtins/compiler-rt': checked out 'dfd960b5f1a1751b22738fa34fd27b583f4618db'
[00:00:11] Submodule path 'src/liblibc': checked out 'a7e78a78e17c8776d7780008ccb3ce541ec64ae9'
---
[00:45:36]    Compiling toml-query v0.6.0
[00:45:51]    Compiling mdbook v0.1.7
[00:46:07]    Compiling ammonia v1.1.0
[00:46:52]    Compiling rustbook v0.1.0 (file:///checkout/src/tools/rustbook)
[00:46:56] error: linking with `cc` failed: exit code: 1
[00:46:56]   |
[00:46:56]   = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/rustbook-4dac10098ae469fd.rustbook0-81f258f1651a8949613a43d78e813490.rs.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/rustbook-4dac10098ae469fd.rustbook1-81f258f1651a8949613a43d78e813490.rs.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/rustbook-4dac10098ae469fd.rustbook10-81f258f1651a8949613a43d78e813490.rs.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/rustbook-4dac10098ae469fd.rustbook11-81f258f1651a8949613a43d78e813490.rs.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/rustbook-4dac10098ae469fd.rustbook12-81f258f1651a8949613a43d78e813490.rs.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/rustbook-4dac10098ae469fd.rustbook13-81f258f1651a8949613a43d78e813490.rs.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/rustbook-4dac10098ae469fd.rustbook14-81f258f1651a8949613a43d78e813490.rs.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/rustbook-4dac10098ae469fd.rustbook15-81f258f1651a8949613a43d78e813490.rs.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/rustbook-4dac10098ae469fd.rustbook2-81f258f1651a8949613a43d78e813490.rs.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/rustbook-4dac10098ae469fd.rustbook3-81f258f1651a8949613a43d78e813490.rs.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/rustbook-4dac10098ae469fd.rustbook4-81f258f1651a8949613a43d78e813490.rs.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/rustbook-4dac10098ae469fd.rustbook5-81f258f1651a8949613a43d78e813490.rs.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/rustbook-4dac10098ae469fd.rustbook6-81f258f1651a8949613a43d78e813490.rs.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/rustbook-4dac10098ae469fd.rustbook7-81f258f1651a8949613a43d78e813490.rs.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/rustbook-4dac10098ae469fd.rustbook8-81f258f1651a8949613a43d78e813490.rs.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/rustbook-4dac10098ae469fd.rustbook9-81f258f1651a8949613a43d78e813490.rs.rcgu.o" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/ruslibhtml5ever-e9b0480d645877bc.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/libmarkup5ever-45a3fa3c8f50cf26.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/libtendril-1fa0266a0fdd48f4.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/libutf8-c53d2b8091f8cf85.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/libfutf-a2d0833f69075cd9.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/libmac-dda845c3bf96a75e.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/libphf-c2e223e664945524.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/libstring_cache-33fc0799fbf4d8a3.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/libstring_cache_shared-d780971f15b243a8.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/libprecomputed_hash-6c33419035452bde.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/libphf_shared-b6f92f93eeb8847c.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/libsiphasher-0c4a235bf4a8eca0.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/libdebug_unreachable-f65fa442cee6b36f.rlib" "/checkout/objnu/release/deps/libeither-1385972965b47156.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/libhandlebars-f2e712be85fab61c.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/libserde_json-e0206a08a0341fa3.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/libitoa-e984df9fdec6a79e.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/libdtoa-0d7eeee04a4b004a.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/libnum_traits-b05ebfbbf4f0f6d0.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/libserde-eb4005638243532f.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/libregex-de19cee1b1f0adf5.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/libutf8_ranges-976fc0e0ee745949.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/libregex_syntax-e1ce736ad751367c.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/libucd_util-f39b1c4d4c3795fc.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/libthread_local-07db5cf592d1dfa5.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/libunreachable-0cdf0a29a2badcee.rlib" "/checkout/objlf.c:(.text.backtrace_uncompress_zdebug+0x0): multiple definition of `backtrace_uncompress_zdebug'
[00:46:56]           /checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/libbacktrace_sys-aaae20e93de8a656.rlib(elf.o):elf.c:(.text.backtrace_uncompress_zdebug+0x0): first defined here
[00:46:56]           collect2: error: ld returned 1 exit status
[00:46:56] 
[00:46:56] error: aborting due to previous error
[00:46:56] 
[00:46:56] error: Could not compile `rustbook`.
[00:46:56] error: Could not compile `rustbook`.
[00:46:56] 
[00:46:56] Caused by:
[00:46:56]   process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustc --crate-name rustbook tools/rustbook/src/main.rs --color always --error-format json --crate-type bin --emit=dep-info,link -C opt-level=3 -C metadata=4dac10098ae469fd -C extra-filename=-4dac10098ae469fd --out-dir /checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/release/deps --extern clap=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/libclap-c6ebe77f170efbdb.rlib --extern mdbook=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps/libmdbook-f5986818c87e8c60.rlib -L native=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/build/backtrace-sys-ed8f2edb5fd55ff0/out/.libs` (exit code: 101)
[00:46:56] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--manifest-path" "/checkout/src/tools/rustbook/Cargo.toml" "--features" "" "--message-format" "json"
[00:46:56] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap doc
[00:46:56] Build completed unsuccessfully in 0:05:24
[00:46:56] Build completed unsuccessfully in 0:05:24
[00:46:56] Makefile:28: recipe for target 'all' failed
[00:46:56] make: *** [all] Error 1
51364 ./obj/build/x86_64-unknown-linux-gnu/stage0/bin
48504 ./obj/build/x86_64-unknown-linux-gnu/stage0-std
47868 ./src/test
47328 ./obj/build/x86_64-unknown-linux-gnu/stage1-std/release

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@alexcrichton
Copy link
Member

@bors: r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 23, 2018
@alexcrichton alexcrichton force-pushed the update-libbacktrace branch from 6691dae to b3ee81e Compare May 23, 2018 03:56
@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented May 23, 2018

📌 Commit b3ee81e has been approved by alexcrichton

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 23, 2018
@steveklabnik steveklabnik force-pushed the update-libbacktrace branch from b3ee81e to 2a33e9b Compare May 23, 2018 14:51
@steveklabnik
Copy link
Member Author

Ugh, pinged @alexcrichton on chat about this; I didn't see that he updated the PR, so just did it and force pushed my version. Oops. Hopefully he can restore soon.

@kennytm kennytm added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 23, 2018
@bors
Copy link
Contributor

bors commented May 30, 2018

📌 Commit 7c14a54 has been approved by alexcrichton

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 30, 2018
@kennytm
Copy link
Member

kennytm commented May 30, 2018

@bors p=162

@bors
Copy link
Contributor

bors commented May 30, 2018

⌛ Testing commit 7c14a54 with merge 74d0939...

bors added a commit that referenced this pull request May 30, 2018
Update libbacktrace

We haven't updated libbacktrace in two years. This is just blindly updating to the latest HEAD; I'd like to see what travis says. It at least builds on my machine, running some tests...

This perpetuates the patches from #30908
@bors
Copy link
Contributor

bors commented May 30, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing 74d0939 to master...

@bors bors merged commit 7c14a54 into rust-lang:master May 30, 2018
@nikic
Copy link
Contributor

nikic commented Jun 2, 2018

Since this commit I'm getting 150 ui test failures (also compile-fail, anything involving failures really). Some of them are segfaults (sample backtrace: https://gist.github.com/nikic/0b752e8aecf12930e488bbfc9bfbd7f1). Most are "panicked while panicking", with the partial trace looking something like

stack backtrace:
   0:     0x7f8e3cd9bc2e - std::sys::unix::backtrace::tracing::imp::unwind_backtrace::ha82b397ea71be585
   1:     0x7f8e3cd71796 - std::sys_common::backtrace::print::h0f02aefa57d1295d
   2:     0x7f8e3cd782bd - std::panicking::default_hook::{{closure}}::hb248860985868cdd
   3:     0x7f8e3cd78030 - std::panicking::default_hook::h0dd63170d2171fd8
   4:     0x7f8e393070d5 - rustc::util::common::panic_hook::h5a856d10e946cf82
   5:     0x7f8e3cd78943 - std::panicking::rust_panic_with_hook::h470a7ba29e7f6e22
   6:     0x7f8e3cd7853c - std::panicking::begin_panic_fmt::hdda42c41c88b4167
   7:     0x7f8e3cd78501 - rust_begin_unwind
   8:     0x7f8e3cdcf722 - core::panicking::panic_fmt::hd47ce5be3b71cd97
   9:     0x7f8e3d15c4a5 - core::result::unwrap_failed::h38f2e7889fea9e60
  10:     0x7f8e3d182df4 - <arena::TypedArena<T> as core::ops::drop::Drop>::drop::h694e59aa0a4a1d47
  11:     0x7f8e3d0da9cc - core::ptr::drop_in_place::h0d7fde6281af2c84
  12:     0x7f8e3d0eeaf9 - rustc_driver::driver::compile_input::he84fc71bb26c3ae0
  13:                0x3 - <unknown>
thread panicked while panicking. aborting.

In both cases the trace contains a weird low-address function (0x1 for the segfault, 0x3 for the panic).

I checked that this happens with 74d0939 but not 4f99f37.

@kennytm
Copy link
Member

kennytm commented Jun 2, 2018

@nikic Could you file a new issue about this?

@nikic
Copy link
Contributor

nikic commented Jun 2, 2018

@kennytm Done in #51295 :)

alexcrichton added a commit to alexcrichton/rust that referenced this pull request Jul 17, 2020
This commit is a proof-of-concept for switching the standard library's
backtrace symbolication mechanism on most platforms from libbacktrace to
gimli. The standard library's support for `RUST_BACKTRACE=1` requires
in-process parsing of object files and DWARF debug information to
interpret it and print the filename/line number of stack frames as part
of a backtrace.

Historically this support in the standard library has come from a
library called "libbacktrace". The libbacktrace library seems to have
been extracted from gcc at some point and is written in C. We've had a
lot of issues with libbacktrace over time, unfortunately, though. The
library does not appear to be actively maintained since we've had
patches sit for months-to-years without comments. We have discovered a
good number of soundness issues with the library itself, both when
parsing valid DWARF as well as invalid DWARF. This is enough of an issue
that the libs team has previously decided that we cannot feed untrusted
inputs to libbacktrace. This also doesn't take into account the
portability of libbacktrace which has been difficult to manage and
maintain over time. While possible there are lots of exceptions and it's
the main C dependency of the standard library right now.

For years it's been the desire to switch over to a Rust-based solution
for symbolicating backtraces. It's been assumed that we'll be using the
Gimli family of crates for this purpose, which are targeted at safely
and efficiently parsing DWARF debug information. I've been working
recently to shore up the Gimli support in the `backtrace` crate. As of a
few weeks ago the `backtrace` crate, by default, uses Gimli when loaded
from crates.io. This transition has gone well enough that I figured it
was time to start talking seriously about this change to the standard
library.

This commit is a preview of what's probably the best way to integrate
the `backtrace` crate into the standard library with the Gimli feature
turned on. While today it's used as a crates.io dependency, this commit
switches the `backtrace` crate to a submodule of this repository which
will need to be updated manually. This is not done lightly, but is
thought to be the best solution. The primary reason for this is that the
`backtrace` crate needs to do some pretty nontrivial filesystem
interactions to locate debug information. Working without `std::fs` is
not an option, and while it might be possible to do some sort of
trait-based solution when prototyped it was found to be too unergonomic.
Using a submodule allows the `backtrace` crate to build as a submodule
of the `std` crate itself, enabling it to use `std::fs` and such.

Otherwise this adds new dependencies to the standard library. This step
requires extra attention because this means that these crates are now
going to be included with all Rust programs by default. It's important
to note, however, that we're already shipping libbacktrace with all Rust
programs by default and it has a bunch of C code implementing all of
this internally anyway, so we're basically already switching
already-shipping functionality to Rust from C.

* `object` - this crate is used to parse object file headers and
  contents. Very low-level support is used from this crate and almost
  all of it is disabled. Largely we're just using struct definitions as
  well as convenience methods internally to read bytes and such.

* `addr2line` - this is the main meat of the implementation for
  symbolication. This crate depends on `gimli` for DWARF parsing and
  then provides interfaces needed by the `backtrace` crate to turn an
  address into a filename / line number. This crate is actually pretty
  small (fits in a single file almost!) and mirrors most of what
  `dwarf.c` does for libbacktrace.

* `miniz_oxide` - the libbacktrace crate transparently handles
  compressed debug information which is compressed with zlib. This crate
  is used to decompress compressed debug sections.

* `gimli` - not actually used directly, but a dependency of `addr2line`.

* `adler32`- not used directly either, but a dependency of
  `miniz_oxide`.

The goal of this change is to improve the safety of backtrace
symbolication in the standard library, especially in the face of
possibly malformed DWARF debug information. Even to this day we're still
seeing segfaults in libbacktrace which could possibly become security
vulnerabilities. This change should almost entirely eliminate this
possibility whilc also paving the way forward to adding more features
like split debug information.

Some references for those interested are:

* Original addition of libbacktrace - rust-lang#12602
* OOM with libbacktrace - rust-lang#24231
* Backtrace failure due to use of uninitialized value - rust-lang#28447
* Possibility to feed untrusted data to libbacktrace - rust-lang#21889
* Soundness fix for libbacktrace - rust-lang#33729
* Crash in libbacktrace - rust-lang#39468
* Support for macOS, never merged - ianlancetaylor/libbacktrace#2
* Performance issues with libbacktrace - rust-lang#29293, rust-lang#37477
* Update procedure is quite complicated due to how many patches we
  need to carry - rust-lang#50955
* Libbacktrace doesn't work on MinGW with dynamic libs - rust-lang#71060
* Segfault in libbacktrace on macOS - rust-lang#71397

Switching to Rust will not make us immune to all of these issues. The
crashes are expected to go away, but correctness and performance may
still have bugs arise. The gimli and `backtrace` crates, however, are
actively maintained unlike libbacktrace, so this should enable us to at
least efficiently apply fixes as situations come up.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 18, 2020
…Simulacrum

std: Switch from libbacktrace to gimli

This commit is a proof-of-concept for switching the standard library's
backtrace symbolication mechanism on most platforms from libbacktrace to
gimli. The standard library's support for `RUST_BACKTRACE=1` requires
in-process parsing of object files and DWARF debug information to
interpret it and print the filename/line number of stack frames as part
of a backtrace.

Historically this support in the standard library has come from a
library called "libbacktrace". The libbacktrace library seems to have
been extracted from gcc at some point and is written in C. We've had a
lot of issues with libbacktrace over time, unfortunately, though. The
library does not appear to be actively maintained since we've had
patches sit for months-to-years without comments. We have discovered a
good number of soundness issues with the library itself, both when
parsing valid DWARF as well as invalid DWARF. This is enough of an issue
that the libs team has previously decided that we cannot feed untrusted
inputs to libbacktrace. This also doesn't take into account the
portability of libbacktrace which has been difficult to manage and
maintain over time. While possible there are lots of exceptions and it's
the main C dependency of the standard library right now.

For years it's been the desire to switch over to a Rust-based solution
for symbolicating backtraces. It's been assumed that we'll be using the
Gimli family of crates for this purpose, which are targeted at safely
and efficiently parsing DWARF debug information. I've been working
recently to shore up the Gimli support in the `backtrace` crate. As of a
few weeks ago the `backtrace` crate, by default, uses Gimli when loaded
from crates.io. This transition has gone well enough that I figured it
was time to start talking seriously about this change to the standard
library.

This commit is a preview of what's probably the best way to integrate
the `backtrace` crate into the standard library with the Gimli feature
turned on. While today it's used as a crates.io dependency, this commit
switches the `backtrace` crate to a submodule of this repository which
will need to be updated manually. This is not done lightly, but is
thought to be the best solution. The primary reason for this is that the
`backtrace` crate needs to do some pretty nontrivial filesystem
interactions to locate debug information. Working without `std::fs` is
not an option, and while it might be possible to do some sort of
trait-based solution when prototyped it was found to be too unergonomic.
Using a submodule allows the `backtrace` crate to build as a submodule
of the `std` crate itself, enabling it to use `std::fs` and such.

Otherwise this adds new dependencies to the standard library. This step
requires extra attention because this means that these crates are now
going to be included with all Rust programs by default. It's important
to note, however, that we're already shipping libbacktrace with all Rust
programs by default and it has a bunch of C code implementing all of
this internally anyway, so we're basically already switching
already-shipping functionality to Rust from C.

* `object` - this crate is used to parse object file headers and
  contents. Very low-level support is used from this crate and almost
  all of it is disabled. Largely we're just using struct definitions as
  well as convenience methods internally to read bytes and such.

* `addr2line` - this is the main meat of the implementation for
  symbolication. This crate depends on `gimli` for DWARF parsing and
  then provides interfaces needed by the `backtrace` crate to turn an
  address into a filename / line number. This crate is actually pretty
  small (fits in a single file almost!) and mirrors most of what
  `dwarf.c` does for libbacktrace.

* `miniz_oxide` - the libbacktrace crate transparently handles
  compressed debug information which is compressed with zlib. This crate
  is used to decompress compressed debug sections.

* `gimli` - not actually used directly, but a dependency of `addr2line`.

* `adler32`- not used directly either, but a dependency of
  `miniz_oxide`.

The goal of this change is to improve the safety of backtrace
symbolication in the standard library, especially in the face of
possibly malformed DWARF debug information. Even to this day we're still
seeing segfaults in libbacktrace which could possibly become security
vulnerabilities. This change should almost entirely eliminate this
possibility whilc also paving the way forward to adding more features
like split debug information.

Some references for those interested are:

* Original addition of libbacktrace - rust-lang#12602
* OOM with libbacktrace - rust-lang#24231
* Backtrace failure due to use of uninitialized value - rust-lang#28447
* Possibility to feed untrusted data to libbacktrace - rust-lang#21889
* Soundness fix for libbacktrace - rust-lang#33729
* Crash in libbacktrace - rust-lang#39468
* Support for macOS, never merged - ianlancetaylor/libbacktrace#2
* Performance issues with libbacktrace - rust-lang#29293, rust-lang#37477
* Update procedure is quite complicated due to how many patches we
  need to carry - rust-lang#50955
* Libbacktrace doesn't work on MinGW with dynamic libs - rust-lang#71060
* Segfault in libbacktrace on macOS - rust-lang#71397

Switching to Rust will not make us immune to all of these issues. The
crashes are expected to go away, but correctness and performance may
still have bugs arise. The gimli and `backtrace` crates, however, are
actively maintained unlike libbacktrace, so this should enable us to at
least efficiently apply fixes as situations come up.

---

I want to note that my purpose for creating a PR here is to start a conversation about this. I think that all the various pieces are in place that this is compelling enough that I think this transition should be talked about seriously. There are a number of items which still need to be addressed before actually merging this PR, however:

* [ ] `gimli` needs to be published to crates.io
* [ ] `addr2line` needs a publish
* [ ] `miniz_oxide` needs a publish
* [ ] Tests probably shouldn't recommend the `gimli` crate's traits for implementing
* [ ] The `backtrace` crate's branch changes need to be merged to the master branch (rust-lang/backtrace-rs#349)
* [ ] The support for `libbacktrace` on some platforms needs to be audited to see if we should support more strategies in the gimli implementation - rust-lang/backtrace-rs#325, rust-lang/backtrace-rs#326, rust-lang/backtrace-rs#350, rust-lang/backtrace-rs#351

Most of the merging/publishing I'm not actively pushing on right now. It's a bit wonky for crates to support libstd so I'm holding off on pulling the trigger everywhere until there's a bit more discussion about how to go through with this. Namely rust-lang/backtrace-rs#349 I'm going to hold off merging until we decide to go through with the submodule strategy.

In any case this is a pretty major change, so I suspect that the compiler team is likely going to be interested in this. I don't mean to force changes by dumping a bunch of code by any means. Integration of external crates into the standard library is so difficult I wanted to have a proof-of-concept to review while talking about whether to do this at all (hence the PR), but I'm more than happy to follow any processes needed to merge this. I must admit though that I'm not entirely sure myself at this time what the process would be to decide to merge this, so I'm hoping others can help me figure that out!
alexcrichton added a commit to alexcrichton/rust that referenced this pull request Jul 28, 2020
This commit is a proof-of-concept for switching the standard library's
backtrace symbolication mechanism on most platforms from libbacktrace to
gimli. The standard library's support for `RUST_BACKTRACE=1` requires
in-process parsing of object files and DWARF debug information to
interpret it and print the filename/line number of stack frames as part
of a backtrace.

Historically this support in the standard library has come from a
library called "libbacktrace". The libbacktrace library seems to have
been extracted from gcc at some point and is written in C. We've had a
lot of issues with libbacktrace over time, unfortunately, though. The
library does not appear to be actively maintained since we've had
patches sit for months-to-years without comments. We have discovered a
good number of soundness issues with the library itself, both when
parsing valid DWARF as well as invalid DWARF. This is enough of an issue
that the libs team has previously decided that we cannot feed untrusted
inputs to libbacktrace. This also doesn't take into account the
portability of libbacktrace which has been difficult to manage and
maintain over time. While possible there are lots of exceptions and it's
the main C dependency of the standard library right now.

For years it's been the desire to switch over to a Rust-based solution
for symbolicating backtraces. It's been assumed that we'll be using the
Gimli family of crates for this purpose, which are targeted at safely
and efficiently parsing DWARF debug information. I've been working
recently to shore up the Gimli support in the `backtrace` crate. As of a
few weeks ago the `backtrace` crate, by default, uses Gimli when loaded
from crates.io. This transition has gone well enough that I figured it
was time to start talking seriously about this change to the standard
library.

This commit is a preview of what's probably the best way to integrate
the `backtrace` crate into the standard library with the Gimli feature
turned on. While today it's used as a crates.io dependency, this commit
switches the `backtrace` crate to a submodule of this repository which
will need to be updated manually. This is not done lightly, but is
thought to be the best solution. The primary reason for this is that the
`backtrace` crate needs to do some pretty nontrivial filesystem
interactions to locate debug information. Working without `std::fs` is
not an option, and while it might be possible to do some sort of
trait-based solution when prototyped it was found to be too unergonomic.
Using a submodule allows the `backtrace` crate to build as a submodule
of the `std` crate itself, enabling it to use `std::fs` and such.

Otherwise this adds new dependencies to the standard library. This step
requires extra attention because this means that these crates are now
going to be included with all Rust programs by default. It's important
to note, however, that we're already shipping libbacktrace with all Rust
programs by default and it has a bunch of C code implementing all of
this internally anyway, so we're basically already switching
already-shipping functionality to Rust from C.

* `object` - this crate is used to parse object file headers and
  contents. Very low-level support is used from this crate and almost
  all of it is disabled. Largely we're just using struct definitions as
  well as convenience methods internally to read bytes and such.

* `addr2line` - this is the main meat of the implementation for
  symbolication. This crate depends on `gimli` for DWARF parsing and
  then provides interfaces needed by the `backtrace` crate to turn an
  address into a filename / line number. This crate is actually pretty
  small (fits in a single file almost!) and mirrors most of what
  `dwarf.c` does for libbacktrace.

* `miniz_oxide` - the libbacktrace crate transparently handles
  compressed debug information which is compressed with zlib. This crate
  is used to decompress compressed debug sections.

* `gimli` - not actually used directly, but a dependency of `addr2line`.

* `adler32`- not used directly either, but a dependency of
  `miniz_oxide`.

The goal of this change is to improve the safety of backtrace
symbolication in the standard library, especially in the face of
possibly malformed DWARF debug information. Even to this day we're still
seeing segfaults in libbacktrace which could possibly become security
vulnerabilities. This change should almost entirely eliminate this
possibility whilc also paving the way forward to adding more features
like split debug information.

Some references for those interested are:

* Original addition of libbacktrace - rust-lang#12602
* OOM with libbacktrace - rust-lang#24231
* Backtrace failure due to use of uninitialized value - rust-lang#28447
* Possibility to feed untrusted data to libbacktrace - rust-lang#21889
* Soundness fix for libbacktrace - rust-lang#33729
* Crash in libbacktrace - rust-lang#39468
* Support for macOS, never merged - ianlancetaylor/libbacktrace#2
* Performance issues with libbacktrace - rust-lang#29293, rust-lang#37477
* Update procedure is quite complicated due to how many patches we
  need to carry - rust-lang#50955
* Libbacktrace doesn't work on MinGW with dynamic libs - rust-lang#71060
* Segfault in libbacktrace on macOS - rust-lang#71397

Switching to Rust will not make us immune to all of these issues. The
crashes are expected to go away, but correctness and performance may
still have bugs arise. The gimli and `backtrace` crates, however, are
actively maintained unlike libbacktrace, so this should enable us to at
least efficiently apply fixes as situations come up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants